public class MyException {
    public static void main(String[] args){
        try{
            MyException.myTest(null);
        } catch(MyAppException me){
            System.out.println("Inside catch block: "+me.getMessage());
        }
    }
     
    static void myTest(String str) throws MyAppException{
        if(str == null){
            throw new MyAppException("\nString val is null");
        }
    }
}
 
class MyAppException extends Exception {
 
    private String message = null;
 
    public MyAppException() {
        super();
    }
 
    public MyAppException(String message) {
        super(message);
        this.message = message;
    }
 
    public MyAppException(Throwable cause) {
        super(cause);
    }
 
    public String toString() {
        return message;
    }
 
    public String getMessage() {
        return message;
    }
}